package com.zhou.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhou.api.entity.Driver;
import com.zhou.mapper.DriverMapper;
import com.zhou.service.DriverService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;

import static com.zhou.utils.CommonCast.NO;
import static com.zhou.utils.CommonCast.YES;

/**
 * @Description : 司机信息
 * @Author : zyy
 * @Date: 2024/9/4  17:54
 */
@Service
@Slf4j
public class DriverServiceImpl extends ServiceImpl<DriverMapper, Driver> implements DriverService {
    /**
     * 添加司机信息
     * @param driver
     */
    @Override
    public void add(Driver driver) {
        baseMapper.insert(driver);
    }

    /**
     * 修改司机信息
     * @param driver
     */
    @Override
    public void update(Driver driver) {
        baseMapper.updateById(driver);
    }

    /**
     * 修改司机状态
     * @param id
     * @param delFlag
     */
    @Override
    public void updateDelFlag(String id, Integer delFlag) {
        Driver driver = this.getById(id);
        if (delFlag == YES) {
            driver.setDelFlag(YES);
            driver.setUpdateTime(new Date());
        }else {
            driver.setDelFlag(NO);
            driver.setUpdateTime(null);
        }
        this.updateById(driver);
    }
}
